﻿using System;
using System.Data;

namespace MvvmOrm.Models.Column
{
    public partial class Row
    {
        public string NameSanitized
        {
            get { return MainViewModel.SanitizeName(_Name); }
        }

        public string PrimaryKeyName
        {
            get { return "PK_" + NameSanitized; }
        }

        public DbType DbTypeEnum
        {
            get { return (DbType)DbType; }
            set { DbType = (int)value; }
        }

        public string DbTypeStringed
        {
            get { return DbTypeEnum.ToString(); }
        }

        public Type Type
        {
            get { return MainViewModel.GetType(DbTypeEnum); }
        }

        public string TypeStringed
        {
            get { return Type.ToString(); }
        }

        public string DefaultValueStringed
        {
            get { return MainViewModel.GetDefaultValueStringed(Nullable, DbTypeEnum); }
        }

        public string NullableSignIfRequired
        {
            get { return Nullable && Type.IsValueType ? "?" : ""; }
        }

        public string TypeWithNullableSign
        {
            get { return TypeStringed + NullableSignIfRequired; }
        }

        public string PrimaryKeyDeclaration
        {
            get { return TypeStringed + " " + PrimaryKeyName; }
        }
    }
}
